package com.team12.hotel404.service.serviceImpl;

import com.team12.hotel404.domain.Power;
import com.team12.hotel404.domain.PowerExample;
import com.team12.hotel404.mapper.PowerMapper;
import com.team12.hotel404.service.PowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PowerServiceImpl implements PowerService {

    @Autowired
    private PowerMapper powerMapper;

    /**
     * 列出所有的权限
     * @return
     */
    @Override
    public List<Power> listAllPower() {
        return powerMapper.selectByExample(new PowerExample());
    }

    /**
     * 更新所有的权限
     * @param power
     */
    @Override
    public void updatePowerInfo(Power power) {
        powerMapper.updateByPrimaryKeySelective(power);
    }

    @Override
    public void insertPower(Power power) {
        powerMapper.insert(power);
    }

    @Override
    public void deletePower(Integer id) {
        powerMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Power findById(Integer id) {
        return powerMapper.selectByPrimaryKey(id);
    }

    @Override
    public int deletePowerById(Integer id) {
        return powerMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Power> findPowerByRoleId(Integer id) {
        return powerMapper.findPowerByRoleId(id);
    }
}
